package cn.itsource.feign.fallback;

import cn.itsource.feign.LogisticFeignClient;
import cn.itsource.pojo.Logistic;
import cn.itsource.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class
LogisticFeignClientFallbackFactory implements FallbackFactory<LogisticFeignClient> {
    @Override
    public LogisticFeignClient create(Throwable throwable) {
        throwable.printStackTrace();
        return new LogisticFeignClient() {
            @Override
            public Logistic queryBySn(Integer oid) {
                return new Logistic(-1,123456,"暂无物流信息",null,null,null,null,null);
            }

            @Override
            public Logistic queryById(Integer id) {
                return new Logistic(-1,123456,"暂无物流信息",null,null,null,null,null);
            }

            @Override
            public AjaxResult saveOrUpdate(Logistic logistic) {
                return AjaxResult.me().setSuccess(false).setMessage("操作失败");
            }
        };
    }
}
